<!--
* description: 快件回复通知  回复 
-->
<template>
  <section class="editBigAreaInfo">
    <el-dialog
      v-dialogDrag
      :close-on-click-modal="false"
      title="快件回复通知"
      :append-to-body="true"
      :visible.sync="curPopupsVisible"
      width="70%"
      @close="closeEdit"
    >
      <dialogHeader
        slot="title"
        title="快件回复通知"
        :style-type="$store.state.app.dialogType"
      />
      <!-- 顶部按钮 -->
      <div class="btns-container">
        <div class="btns-cls">
          <el-button
            v-for="item in tableButtons"
            :key="item.comKey"
            :type="item.type"
            @click="item.clickEvent"
          >
            {{ item.text }}
          </el-button>
        </div>
      </div>
      <!-- 通知信息 -->
      <div class="filter-container filter-title">通知信息</div>
      <div class="filter-container filter-params">
        <el-row ref="vailComponentList1">
          <component
            :is="comp.component"
            v-for="comp in tableComponents1.filter((o) => o.isMust === true)"
            :ref="comp.isRequire ? comp.isRequire + comp.compKey : comp.compKey"
            :key="comp.compKey"
            :validrule="comp.validrule"
            :code-field="comp.codeField"
            :text-field="comp.textField"
            :popups-key="comp.compKey"
            :parent-fileds="comp.parentFileds"
            :code="formField[comp.codeField]"
            :disabled="comp.disabled"
            :o-fields="comp.oFields"
            :options="comp.options"
            :custom-obj="comp.customObj"
            :is-require="comp.isRequire"
            :is-mul="comp.isMul"
            :span="comp.span || 8"
            :label-name="comp.labelName"
            :lookuptype="comp.lookuptype"
            :data-to-object="comp.dataToObj"
            :date-options-type="comp.dateOptionsType"
            @changeCode="getComponentCode"
            @focusCode="getFocusCode"
          />
        </el-row>
      </div>
      <!-- 回复信息 -->
      <div class="filter-container filter-title">回复信息</div>
      <div class="filter-container filter-params">
        <el-row ref="vailComponentList1">
          <component
            :is="comp.component"
            v-for="comp in tableComponents2.filter((o) => o.isMust === true)"
            :ref="comp.isRequire ? comp.isRequire + comp.compKey : comp.compKey"
            :key="comp.compKey"
            :validrule="comp.validrule"
            :code-field="comp.codeField"
            :text-field="comp.textField"
            :popups-key="comp.compKey"
            :parent-fileds="comp.parentFileds"
            :code="formField[comp.codeField]"
            :disabled="comp.disabled"
            :o-fields="comp.oFields"
            :options="comp.options"
            :custom-obj="comp.customObj"
            :is-require="comp.isRequire"
            :is-mul="comp.isMul"
            :span="comp.span || 8"
            :label-name="comp.labelName"
            :lookuptype="comp.lookuptype"
            :data-to-object="comp.dataToObj"
            :date-options-type="comp.dateOptionsType"
            @changeCode="getComponentCode"
            @focusCode="getFocusCode"
          />
        </el-row>
      </div>
      <!-- 返件清单 -->
      <div class="filter-container filter-title">返件清单</div>
      <div class="app-container app-container-table">
        <one-table-template
          ref="multipleTable"
          :key="oneTableKey"
          :dynamic-api-config="apiConfig"
          :dynamic-table-cols="tableHeader_1"
          :dynamic-form-fields="formField"
          :dynamic-is-init-table="true"
          :dynamic-table-defult-height="300"
        />
      </div>
    </el-dialog>
  </section>
</template>
<script>
import { formMixins } from "@/components/mixins/formMixins";
import OneTableTemplate from "@/components/templates/oneTable";
import api from "@/api/se/coreManagement";
import request from "@/utils/request";
export default {
  components: {
    dialogHeader: () => import("@/components/dialogHeader"),
    mixButton: () => import("@/components/basicComponent/mixButton"),
    OneTableTemplate,
  },

  // 组件混入对象
  mixins: [formMixins],

  props: {
    // 从网格传入的编辑数据组(json)
    dynamicEditRowData: {
      type: Object,
      default: function () {
        return {};
      },
    },
  },

  data() {
    const viewPageCode = "bigAreaInfo-edit";
    return {
      // 动态组件-按钮
      tableButtons: [
        {
          compKey: "btnKey1",
          type: "primary",
          size: "small",
          icon: "iconfont  icon-preservation",
          clickEvent: () => this.callBack(),
          text: "回复" /* 保存*/,
          position: "right",
        },
      ],
      tableComponents1: [
        {
          compKey: "key0",
          labelName: "通知编号：",
          codeField: "notifyCode",
          isMul: false,
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true,
          disabled: true,
        },
        {
          compKey: "key1",
          labelName: "发布人：",
          codeField: "empName",
          isMul: false,
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true,
          disabled: true,
        },
        {
          compKey: "key2",
          labelName: "联系电话：",
          codeField: "workTel",
          isMul: false,
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true,
          disabled: true,
        },
        {
          compKey: "key3",
          labelName: "到件截止日期：",
          codeField: "expiryDate",
          isMul: false,
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true,
          disabled: true,
        },
        {
          compKey: "key4",
          labelName: "收件人：",
          codeField: "consignor",
          isMul: false,
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true,
          disabled: true,
        },
        {
          compKey: "key5",
          labelName: "收件人电话：",
          codeField: "mobile",
          isMul: false,
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true,
          disabled: true,
        },
        {
          compKey: "key6",
          labelName: "收件人地址：",
          codeField: "address",
          span: 16,
          isMul: false,
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true,
          disabled: true,
        },
        {
          compKey: "key7",
          labelName: "索赔单号：",
          codeField: "preAuthorCode",
          isMul: false,
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true,
          disabled: true,
        },
        {
          compKey: "key8",
          labelName: "VIN：",
          codeField: "vin",
          isMul: false,
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true,
          disabled: true,
        },
        {
          compKey: "key9",
          labelName: "车型：",
          codeField: "carConfigCn",
          isMul: false,
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true,
          disabled: true,
        },
        {
          compKey: "key10",
          labelName: "主损件编码：",
          codeField: "mainPartCode",
          isMul: false,
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true,
          disabled: true,
        },
        {
          compKey: "key11",
          labelName: "详细要求：",
          codeField: "remark",
          // component: () => import("@/components/org/commonInput"),
          component: () => import("@/components/org/commonInput/textareaInput"),
          type: "dropdownList",
          isMust: true,
          disabled: true,
          span: 16,
        },
        {
          compKey: "key12",
          labelName: "主损件名称：",
          codeField: "mainPartName",
          isMul: false,
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true,
          disabled: true,
        },
        {
          compKey: "key13",
          labelName: "通知状态：",
          codeField: "status",
          component: () => import("@/components/org/LookupValue"),
          oFields: "statusId,statusText",
          options: [
            { statusId: "0", statusText: "已发布" },
            { statusId: "1", statusText: "已回复" },
          ],
          type: "dropdownList",
          isMust: true,
          disabled: true,
        },

        {
          compKey: "key14",
          labelName: "门店编号：",
          codeField: "dlrCode",
          isMul: false,
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true,
          disabled: true,
        },
        {
          compKey: "key15",
          labelName: "门店名称：",
          codeField: "dlrName",
          isMul: false,
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true,
          disabled: true,
        },
      ],
      tableComponents2: [
        {
          compKey: "key0",
          labelName: "回复说明：",
          codeField: "repleyRemark",
          isMul: false,
          component: () => import("@/components/org/commonInput"),
          type: "inputText",
          isMust: true,
          span: 24,
        },
      ],
      tableHeader_1: [
        {
          label: "备件编号",
          prop: "partNo",
        },
        {
          label: "备件名称",
          prop: "partName",
        },
        {
          label: "备注",
          prop: "remark",
        },
      ],
      // 表单数据（无需赋值，由混入对象赋值）
      formField: this.$utils.getFormField(
        this,
        {
          notifyId: "",
          notifyCode: "",
          empName: "",
          workTel: "",
          expiryDate: "",
          consignor: "",
          mobile: "",
          address: "",
          preAuthorCode: "",
          vin: "",
          carConfigCn: "",
          mainPartCode: "",
          remark: "",
          mainPartName: "",
          status: "",
          dlrCode: "",
          dlrName: "",
          repleyRemark: "",
        },
        this.$ConfigCache.CacheConfig.cacheData[viewPageCode]
      ),
    };
  },
  watch: {
    popupsVisible(val, old) {
      if (val) {
        this.findDetail();
      }
    },
  },
  methods: {
    findDetail() {
      request({
        url: api.queryReturnParts.APIUrl,
        method: "post",
        data: { preAuthorCode: this.formField.preAuthorCode },
      }).then((res) => {
        if (res.result == "1") {
          this.$refs["table_1"].list = res.rows;
        }
      });
    },
    callBack() {
      request({
        url: api.updateReturnParts.APIUrl,
        method: "post",
        data: {
          notifyId: this.formField.notifyId,
          repleyRemark: this.formField.repleyRemark,
          status: this.formField.status,
        },
      }).then((res) => {
        if (res.result == "1") {
          this.$message.success("回复成功");
          this.curPopupsVisible = false;
          this.$parent.queryTable(1);
        }
      });
    },

    closeEdit() {
      this.$emit("close", false);
    },
  },
};
</script>

<style lang="scss" scoped>
.btns-container {
  background-color: #fff;
  overflow: hidden;
  padding-right: 20px;
  .btns-cls {
    float: right;
  }
}
</style>

